<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!-- 写了个公共类，把要导入的公共的文件写到一块，${ctx} -->		    
<%@include file="/WEB-INF/jsp/common/taglibs.jsp"%>       
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="${ctx}/lib/bootstrap-3.3.7-dist/css/bootstrap.css" />
<script type="text/javascript" src="${ctx}/lib/jquery/jquery-1.11.1.js" ></script>
<script type="text/javascript" src="${ctx}/lib/bootstrap-3.3.7-dist/js/npm.js" ></script>
<script type="text/javascript" src="${ctx}/lib/layer-v3.1.1/layer/layer.js" ></script>
<script type="text/javascript" src="${ctx}/lib/bootstrap-3.3.7-dist/js/mylayer.js" ></script>
</head>
<body>
	<form id="updata_form" action="${ctx}/course/update.action" method="post">
	<!-- value 默认显示拿到的值（拿到原来的值） -->
		<input type="hidden" name="id" value="${course.id}"/>
		课程名称：<input type="text" name="name" value="${course.name}"  /><br/>
		课程分值：<input type="text" name="credit" value="${course.credit}"/><br/>
		课程时长：<input type="text" name="classhour" value="${course.classhour}"/><br/>
		<br/> 
		<input type="button" onclick="update()" value="修改"/>
		<input type="reset" value="重置"/>
	</form>
	<script type="text/javascript">
		function update(){
			$.ajax({
				url : "${ctx}/course/update.action",
				type : "post",
				dataType : "json",
				data : $("#updata_form").serialize(),
				success : function(data){
					if(data){
						mylayer.success("修改成功");
						var index = parent.layer.getFrameIndex(window.name);
						setTimeout(function(){
							parent.layer.close(index);
							window.parent.location.reload();
						},1000)
					} else {
						mylayer.errorMsg("修改失败");
					}
				}
			});
		}
	</script>
</body>
</html>